/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AnalysistImpl;

import AnalysistInterface.IAnalysist;
import CommonValue.Pressure;
import DTO.DrawDTO;
import DTO.SensorDTO;
import DTO.PacketDTO;
import java.util.Date;
import java.util.HashMap;

/**
 *
 * @author Administrator
 */
public class PressureAnalysist extends BaseAnalysist implements IAnalysist {

    public PressureAnalysist() {
        setAnalysistSign(Pressure.SIGN);
    }

    @Override
    public DrawDTO analysis(String location, PacketDTO _packet) {
        HashMap<Date, Float> pressureMap = new HashMap<Date, Float>();
        DrawDTO report = new DrawDTO();
        for (SensorDTO i : _packet.getBuffer()) {
            if (isMatchSign(i) && i.getLocation().equalsIgnoreCase(location)) {
                pressureMap.put(i.getCreatTime(), i.getData().get(Pressure.PRESSURE));
            }
        }
        report.add(Pressure.PRESSURE, pressureMap);
        return report;
    }

    @Override
    public DrawDTO analysis(String location, PacketDTO _packet, Date fromDate, Date toDate) {
        HashMap<Date, Float> pressureMap = new HashMap<Date, Float>();
        DrawDTO report = new DrawDTO();
        for (SensorDTO i : _packet.getBuffer()) {
            if (isMatchSign(i) && i.getLocation().equalsIgnoreCase(location)) {
                if ((i.getCreatTime().compareTo(fromDate) >= 0) && (i.getCreatTime().compareTo(toDate) <= 0)) {
                    pressureMap.put(i.getCreatTime(), i.getData().get(Pressure.PRESSURE));
                }
            }
        }
        report.add(Pressure.PRESSURE, pressureMap);
        return report;
    }
}
